/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.miracleteam.miracle.dao.daoImpl;

import com.miracleteam.miracle.dao.LayoutGiaoDienDAO;
import com.miracleteam.miracle.entities.Layoutgiaodiengianhang;
import com.miracleteam.miracle.utils.HibernateUtil;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author DangKhoa
 */
public class LayoutGiaoDienDAOImpl implements LayoutGiaoDienDAO{
    Logger logger= Logger.getLogger(LayoutGiaoDienDAOImpl.class);
    public Layoutgiaodiengianhang LayLayoutGiaoDien(String maGianHang) {
        Layoutgiaodiengianhang lyo = null;
        Session session = HibernateUtil.getSessionFactory().openSession();
        try {
           
            String hql = "from Layoutgiaodiengianhang where maGianHang =:maGH";
            Query query = session.createQuery(hql);
            query.setString("maGH", maGianHang);
            Object ob = query.uniqueResult();
            lyo =  (Layoutgiaodiengianhang)ob;
        } catch (HibernateException e) {
             logger.error(e.getMessage());
        } finally {
            session.close();
        }
        return lyo;
    }
    
}
